<?php
declare (strict_types=1);

namespace app\validate;

use think\Validate;

class UserLevelValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id' => 'require',
        'name' => 'require',
        'amount' => 'require|egt:0',
        'img' => 'require',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'id.require' => 'id不能为空',
        'name.require' => '等级名称不能为空',
        'amount.require' => '累计积分不能为空',
        'amount.egt' => '累计积分必须大于等于0',
        'img.require' => '等级图片不能为空',
    ];

    protected $scene = [
        'add' => ['name', 'amount', 'img'],
        'edit' => ['id', 'name', 'amount', 'img'],
    ];
}
